package com.room.service;

import com.room.utils.EmailUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

/**
 * @创建人 lin
 * @创建时间 2019/10/9
 * @描述
 */
@Service
@PropertySource("classpath:application.properties")
public class SendemailService {
    @Autowired
    private JavaMailSender mailSender;

    @Value("${spring.mail.username}")
    private String from;


    public String sendEmail(String to, String msg) {
        String content = "本次操作的验证码是："+msg+"该验证码1分钟后失效，请注意保密，不要外传";
        new EmailUtil().sendEmail(mailSender,from,to,"宿舍管理系统",content);
        return msg;
    }
}
